<div class="section">

	<div class="section-title">Quản lý loại báo</div>
    
    <div class="section-content">
    	
        <form action="" method="post" id="listitem" name="listitem">
        
        	<div class="button right">
            	<?php if($list_button['insert']){ ?>
                <a class="button add" href="<?php echo $insert?>">Thêm mới</a>
                <?php } ?>
                <?php if($list_button['delete']){ ?>
                <a class="button delete" onclick="deleteItem()">Xóa</a>
                <?php } ?>
                <a class="button exit" href="?route=deliman/home">Về trang chủ</a>
            </div>
            <div class="clearer">^&nbsp;</div>
            <div class="text-center"  style="padding-left:50px">
            	<div class="left">
					<input type="text" style="border: 1px solid #CCC; height:20px" class="text" id="txtSearch" name="txtSearch" size="30" value="" />
                </div>
                <div class="left">
                	<a class="button-other search" id="searchForm"></a>
                </div>
                <div class="clearer">&nbsp;</div>         
             </div>
            <div class="sitemap treeindex">
                <table class="data-table" cellpadding="0" cellspacing="0">
                <tbody>
                    <tr class="tr-head">
                        <th width="1%"><input class="inputchk" type="checkbox" onclick="$('input[name*=\'delete\']').attr('checked', this.checked);"></th>
                        
                        
                        <th>Tên loại báo</th>
                        <th>Công cụ</th>                                  
                    </tr>
        <?php
         if($thongbao==0)
            {
        ?>
        	<tr>
            	<td colspan="3">
                <div class="text-center">
            		<span class="thongbaokhongcodulieu">Không có dữ liệu trong hệ thống</span>
                </div>
                </td>
            </tr>
        
        <?php 
        }else{
        ?>
        
        
        
        <?php
            foreach($datas as $item)
            {
        ?>
                    <tr>
                        <td class="check-column"><input class="inputchk" type="checkbox" name="delete[<?php echo $item['loaibaoid']?>]" value="<?php echo $item['loaibaoid']?>" ></td>
                        
                        <td><?php echo $item['tenloaibao']?></td>
                        
                        <td class="link-control">
                        	<?php if($list_button['update']){ ?>
                           	<a class="button edit" href="<?php echo $item['link_edit']?>">Sửa</a>
                            <?php } ?>
                            </td>
                        </td>
                    </tr>
        <?php
            }
         }
        ?>
                        
                                                    
                </tbody>
                </table>
            </div>
        	<?php echo $pager?>
        
        </form>
        
    </div>
    
</div>
<script language="javascript">
$(document).ready(function(){
	$("#txtSearch").val("<?php echo urldecode($_GET['tenloaibao'])?>");
	
	//search
	
	$('#searchForm').click(function(){
		searchItem();
	});
});

function deleteItem()
{
	var answer = confirm("Bạn có muốn xóa không?")
	if (answer)
	{
		$.post("?route=deliman/loaibao/delete", 
				$("#listitem").serialize(), 
				function(data)
				{
					if(data=="true")
					{
						alert("Xóa thành công");
						window.location.reload();
					}
				}
		);
	}
}

function searchItem()
{
	var url = "?route=deliman/loaibao";
	if(trim($(".text").val()) != "")
		url += "&tenloaibao="+ $(".text").val();
	window.location = url;
}

$("#loaibaoid").val("<?php echo $_GET['loaibaoid']?>");

</script>